<template>
	<view class="w-full  vh-100">
		<!-- <view class="titleStyPOs">
			<div style="height:30rpx"></div>
			<view :style="{height: statusBarHeight + 'px'}"></view>
			<Title :title="title" />
		</view> -->
		<CommonHeader :title="$t('积分账单')" ></CommonHeader>
		<!-- <view style="height: 80rpx;"></view> -->
		<view class="bgSty" >
			<view class="ml-50 pt-25">
				<p class="fz26 text-white">{{$t('当前积分')}}</p>
				<p class="fz60 text-white mt-16 font-bold">{{total}}</p>
			</view>
			<image :src="getImageUrl('/shopstatic/icon/jinbi.png')" mode="" class="w-200 h-200 mr-40"></image>
		</view>
		<view class="billSty">
			<view class="flex between pt-50">
				<view class="ml-35 flex-start">
					<image :src="getImageUrl('/shopstatic/monthBill.png')" mode="" class="w-45 h-45"></image>
					<span class="fz30 text-010 font-bold ml-10">{{$t('账单')}}</span>
				</view>
				<view class="mr-35 dateSty" @click="showTime = true">
					<span class="fz22 text-333 pl-10 pr-10">{{ timeCheck || $t('时间筛选') }}</span>
					<span class="fz22 text-333 pr-10"> > </span>
				</view>
				<!-- <u-picker mode="time" v-model="showTime" :params="params" @confirm="confirmTime" @cancel="showTime = false"></u-picker> -->
			</view>
			<view class="mt-50">
				<view class="listInfoSty" v-for="(item,index) in billList">
					<view class="">
						<p class="fz26 text-333 font-bold">{{item[plang('memo')]}}</p>
						<p class="fz22 mt-10" style="color: #AEAEAE;">{{item.create_at}}</p>
					</view>
					<p class=" fz28" style="color: #FF6600;" v-if="item.type == '+'"> {{ item.score }}</p>
					<p class=" text-333 fz28" v-else> {{ item.score }}</p>
				</view>
			</view>
			<view class="h-220"></view>
			<div v-if="nomore" class="center text-gray-500 fz24 pt-20 pb-20">{{$t('没有更多了')}}</div>
		</view>
		<view class="empty"></view>
		<view class="footer_btn4" @click="toScorePoint">
			<view class="btn_blue" @click="shownewGroup = true">
				{{$t('充值积分')}}
			</view>
		</view>
		<u-calendar v-model="showTime" mode="range" @change="confirmTime" :toolTip="$t('选择日期')" :confirmText="$t('确定')" :start-text="$t('开始')" :end-text="$t('结束')"></u-calendar>
	</view>
</template>

<script>
	import { getScoreTotal, getScoreList } from '@/api/basic'
	// import Title from './../components/title.vue'
	import CommonHeader from "@/pages/components/common-header.vue";
	export default {
		components: {
			// Title,
			CommonHeader
		},
		data() {
			return {
				title: this.$t('积分账单'),
				statusBarHeight: uni.getStorageSync('statusBarHeight') || 0,
				nomore: false,
				showTime: false,
				params: {
					year: true,
					month: true,
					day: true
				},
				timeCheck: '',
				billList: [],
				total: '',
				paramsList: {
					start: '',
					end: '',
					page: 1,
					limit: 100,
				},
				currentPage: 0,
			}
		},
		mounted() {
			this.getScoreTotal()
			this.getScoreList()
		},
		methods: {
			getScoreTotal() {
				getScoreTotal().then(res => {
					this.total = res.data.data.total
				})
			},
			confirmTime(e) {
				console.log('e', e)
				this.timeCheck = e.startDate + '~' + e.endDate;
				this.paramsList.end = e.endDate;
				this.paramsList.start = e.startDate
				this.getScoreList(true)
			},
			toScorePoint() {
				uni.navigateTo({
					url: '/pages/vip/scorePoint',
					webview: 'zWebView'
					// url: "/pages/zWebView/zWebView?url=" + encodeURIComponent(
					// 	`/pages/vip/scorePoint`)
				})
			},
			
			//下拉刷新
			onPullDownRefresh() {
				this.getScoreList(true)
			},
			//上拉加载
			onReachBottom() {
				console.log('this.currentPage', this.currentPage)
				console.log('this.paramsList.page', this.paramsList.page)
				if (this.currentPage > this.paramsList.page) {
					this.paramsList.page++;
					this.getScoreList()
				} else {
					this.nomore = true;
				}
		
			},
			getScoreList(init) {
				uni.showLoading({
					title: 'loading',
					mask: true
				})
				if (init) {
					this.paramsList.page = 1
					this.nomore = false;
				}
				console.log('this.paramsList0000', this.paramsList)
				getScoreList(this.paramsList).then(res => {
					this.currentPage = res.data.data.countPage
					if (this.paramsList.page == 1) {
						this.billList = res.data.data.list
					} else {
						this.billList = [...this.billList, ...res.data.data.list]
					}
					uni.hideLoading()
					//当前请求的{{$t('列表')}}{{$t('是')}}空的 那就{{$t('是')}}没有更多了
					if (res.data.data.length == 0) {
						this.nomore = true;
					}
					// 结束下拉刷新
					uni.stopPullDownRefresh()
				})
			}
		}
	}
</script>

<style lang="scss">
	@import '@/assets/appScss.scss';
	page {
		background-color: #F6F7FB;
	}
	.titleStyPOs {
		position: fixed;
		background-color: #F6F7FB;
		width: 100%;
		z-index: 10;
	}
	.bgSty {
		height: 300rpx;
		background-image: url('https://gluz-oss.oss-cn-beijing.aliyuncs.com/shopstatic/goldBgColor.png');
		background-size: 100% 100%;
		margin-left: 34rpx;
		margin-right: 34rpx;
		display: flex;
		justify-content: space-between;
		// align-items: center;
		margin-top: 50rpx;
		padding-top: 50rpx;
	}
	// .empty {
	// 	width: 100%;
	// 	height: 200rpx;
	// }
	.billSty {
		background-color: #fff;
		width: 100%;
		height: auto;
		margin-top: -60rpx;
		border-radius: 24rpx;
		.dateSty {
			height: 50rpx;
			min-width: 120rpx;
			background-color: #F6F6F6;
			color: #202020;
			font-size: 24rpx;
			text-align: center;
			line-height: 44rpx;
			border-radius: 8rpx;
		}
		.listInfoSty {
			border-bottom: 1rpx solid #F0F0F0;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 28rpx;
			padding-bottom: 18rpx;
			margin-left: 35rpx;
			margin-right: 35rpx;
		}
	}
	.empty {
		width: 100%;
		height: 200rpx;
	}
	.footer_btn4{
		position: fixed;
		left:0;
		bottom: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #fff;
		padding:30rpx 24rpx 60rpx;
		.btn_blue{
			width: 97%;
			height: 94rpx;
			flex-shrink: 0;
			border-radius: 500px;
			background: linear-gradient(90deg, #FF7000 0%, #FFA245 100%);
			box-shadow: 0px 4px 13.8px 0px #DEE1EF;
			box-shadow: -2px -3px 9.9px 0px #FFBE7C inset;
			box-shadow: -4px 4px 6px 0px #FFCB9775 inset;
			font-family: PingFang SC;
			font-weight: 600;
			font-size: 32rpx;
			line-height: 94rpx;
			letter-spacing: 0%;
			text-align: center;
			color: #fff;
		}
		.ico{
			width: 42rpx;
			height: 42rpx;
		}
	}
</style>
